const permissionModel = () => import('@/views/permissionModel/index.vue')
const accountManagement = () => import('@/views/permissionModel/accountManagement')
const accountManagementList = () => import('@/views/permissionModel/accountManagement/pageList/index.vue')
const accountAddEdit = () => import('@/views/permissionModel/accountManagement/addEdit/index.vue')
const roleManagement = () => import('@/views/permissionModel/roleManagement/index.vue')
const roleManagementList = () => import('@/views/permissionModel/roleManagement/pageList/index.vue')
const roleAddEdit = () => import('@/views/permissionModel/roleManagement/addEdit/index.vue')

export default {
  path: 'permission-model',
  name: 'permissionModel',
  component: permissionModel,
  children: [
    {
      path: 'account-management',
      name: 'accountManagement',
      component: accountManagement,
      children: [
        {
          path: 'account-management-list',
          name: 'accountManagementList',
          component: accountManagementList,
          meta: {
            title: '账号管理',
          },
        },
        {
          path: 'account-add-edit',
          name: 'accountAddEdit',
          component: accountAddEdit,
          meta: {
            title: '新增',
          },
          beforeEnter(to, from, next) {
            if (to.query.title === 'edit') {
              to.meta.title = '编辑'
            } else if (to.query.title === 'watch') {
              to.meta.title = '查看'
            } else {
              to.meta.title = '新增'
            }
            next()
          },
        },
      ],
    },
    {
      path: 'role-management',
      name: 'roleManagement',
      component: roleManagement,
      children: [
        {
          path: 'role-management-list',
          name: 'roleManagementList',
          component: roleManagementList,
          meta: {
            title: '角色管理',
          },
        },
        {
          path: 'role-add-edit',
          name: 'roleAddEdit',
          component: roleAddEdit,
          meta: {
            title: '新增',
          },
          beforeEnter(to, from, next) {
            if (to.query.type === 'edit') {
              to.meta.title = '编辑'
            } else if (to.query.type === 'watch') {
              to.meta.title = '查看'
            } else {
              to.meta.title = '新增'
            }
            next()
          },
        },
      ],
    },
  ],
}
